home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.graphics,comp.lang.c++
- Path: nntp.coast.net!torn!nott!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: Re: Drawing from any procedure
- Message-ID: <DosooJ.1uI@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- References: <4iuni1$oep@lily.csv.warwick.ac.uk>
- Date: Sun, 24 Mar 1996 23:17:07 GMT
-
- In article <4iuni1$oep@lily.csv.warwick.ac.uk> esuvx@csv.warwick.ac.uk (Adge) writes:
- >
- >I am programming in ms Visual C++ v.4.0 under Win95, and am trying to
- >persuade it to allow me to draw graphics to a window from a procedure other
- >than OnPaint or OnDraw.
- >
- >I have tried using CPaintDC(this); , but this gives an access violation.
- >
- >It used to be possible under Borland Pascal for win but I can't work out
- >how to do it under visc++
- >
- >Can anyone help ?
- If you respond to WM_PAINT, then you are provided with an HDC
- (presumably your OnPaint does the BeginPaint/EndPaint stuff for you).
-
- If you wish to draw at any other time, you need to obtain an HDC,
- i.e. with GetDC(). Do your drawing and then ReleaseDC().
-
- However, there is a very good reason for doing *ALL* of your drawing
- at WM_PAINT. Consider what happens if you draw something anytime you
- want (i.e. not at WM_PAINT). Your picture looks fine, right? Ok,
- now what happens if your app is covered/uncovered by a dialog box
- or another app? That generates WM_PAINT and you will draw part of
- the picture, but not the part that you drew separately. Remember
- that you must be prepared to paint any or all of your picture at
- any time at WM_PAINT.
- --
- John A. Grant jagrant@emr1.emr.ca
- Airborne Geophysics
- Geological Survey of Canada, Ottawa
-